package com.fkg.test.mvp.presenter;

import com.fkg.test.mvp.modle.User;
import com.fkg.test.mvp.view.ILoginView;

/**
 * Created by FanKaige on 2017/10/18.
 */

public class LoginPresenterCompl implements ILoginPresenter{

    private ILoginView loginView;
    private User user;

    public LoginPresenterCompl(ILoginView loginView) {
        this.loginView = loginView;
        user = new User("123","456");
    }

    @Override
    public void clear() {
        loginView.onClearText();
    }

    @Override
    public void doLogin(String name, String password) {

        boolean result = false;
        int code = 0;

        if (name.equals(user.getName()) && password.equals(user.getPassword())){
            result = true;
            code = 1;
        }else {
            result = false;
            code = 0;
        }

        loginView.onLoginResult(result,code);

    }
}
